function setDelay() {
    let data = {
        second: document.getElementById("delay").value.trim()
    }
    fetch("/api/account/setdelay", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(data)
    })
        .then(res => res.json())
        .then(data => {
            showToast(data.message);
            getDelay();
        })
        .catch(err => console.error(err));
}

function getDelay() {
    fetch("/api/account/getdelay")
        .then(res => res.json())
        .then(data => {
            document.getElementById("delay-time").innerText = "当前延迟: " + data.message + "秒";
        })
        .catch(err => console.error(err));
}

function deleteAllAccount() {
    fetch("/api/account/deleteall")
        .then(res => res.json())
        .then(data => {
            showToast(data.message)
        })
        .catch(err => console.error(err));
}

// 一键踢出未保留账号
function kickNonReserved() {
    fetch("/api/account/kickNonReserved")
        .then(res => res.json())
        .then(data => {
            showToast(data.message)
        })
        .catch(err => console.error(err));
}

getDelay();
